home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0117_Text Screen Fading.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  2KB  |  85 lines

  1. {
  2. I recently found out that you can adjust the colours regardless of what
  3. video mode you happen to be in.  Play around with this program ...
  4.  
  5. ------------------- 8< ------------------------------------
  6. { Simple little program to "fade" out text on the screen.
  7.  
  8.   Feel free to play around with it ...
  9.  
  10.   Doesn't fully work, but should give you a good idea.  Note that it requires
  11.   a VGA (or better) graphics card. }
  12.  
  13. USES CRT;
  14.  
  15. CONST 
  16.   { Colour of DOS text. } 
  17.   DOS_COLOUR = LIGHTGRAY; 
  18.  
  19. TYPE 
  20.   PaletteType = RECORD 
  21.                   R, G, B : BYTE; 
  22.                 End; 
  23.  
  24. VAR 
  25.   Colour, 
  26.   ColourCnt  : BYTE; 
  27.   AllColours : ARRAY[ 0..63 ] OF PaletteType; 
  28.  
  29. BEGIN 
  30.   FOR Colour := 0 TO 16 DO 
  31.   Begin 
  32.     TextColor( Colour ); 
  33.     WriteLn( 'This is some text' );
  34.   End; 
  35.  
  36.   { Read in all the colours of the palette into an array. } 
  37.   FOR Colour := 0 TO 63 DO 
  38.   Begin 
  39.     { Indicate that the palette registers are going to be read } 
  40.     Port[ $3C7 ] := 0; 
  41.  
  42.     AllColours[ Colour ].R := Port[ $3C9 ]; 
  43.     AllColours[ Colour ].G := Port[ $3C9 ]; 
  44.     AllColours[ Colour ].B := Port[ $3C9 ]; 
  45.   End; 
  46.  
  47.   { Fade out any text that is on the screen. } 
  48.   WHILE AllColours[ 61 ].B > 1 DO 
  49.     FOR Colour := 0 TO 63 DO 
  50.     Begin 
  51.       Port[ $3C8 ] := Colour; 
  52.  
  53.       IF AllColours[ Colour ].R > 0 THEN
  54.         DEC( AllColours[ Colour ].R ); 
  55.  
  56.       IF AllColours[ Colour ].G > 0 THEN 
  57.         DEC( AllColours[ Colour ].G ); 
  58.  
  59.       IF AllColours[ Colour ].B > 0 THEN 
  60.         DEC( AllColours[ Colour ].B ); 
  61.  
  62.       Port[ $3C9 ] := AllColours[ Colour ].R; 
  63.       Port[ $3C9 ] := AllColours[ Colour ].G; 
  64.       Port[ $3C9 ] := AllColours[ Colour ].B; 
  65.  
  66.       Delay( 10 ); 
  67.     End; 
  68.  
  69.   TextColor( DOS_COLOUR ); 
  70.  
  71.   ClrScr; 
  72.   WriteLn( 'Watch me fade back in ...' ); 
  73.  
  74.   FOR ColourCnt := 0 TO 42 DO 
  75.   Begin 
  76.     Port[ $3C8 ] := DOS_COLOUR; 
  77.  
  78.     Port[ $3C9 ] := ColourCnt; 
  79.     Port[ $3C9 ] := ColourCnt; 
  80.     Port[ $3C9 ] := ColourCnt; 
  81.  
  82.     Delay( 20 ); 
  83.   End; 
  84. END. 
  85.